import { Subscriber } from "./Subscriber";
// 发布者的接口
export interface IPublisher {
  // 发布者现在只管发布消息
  publish: (topic: string, message: string) => void;
}

// 订阅者的接口
// 现在是由订阅者自己来决定订阅哪个主题
export interface ISubscriber {
  subscribe: (topic: string) => void;
  unsubscribe: (topic: string) => void;
  receive: (message: string) => void;
}

// 中间人的接口
export interface IBroker {
    // 订阅主题
    subscribe: (topic: string, subscriber: Subscriber) => void;
    // 取消订阅
    unsubscribe: (topic: string, subscriber: Subscriber) => void;
    // 发布消息
    publish: (topic: string, message: any) => void;
}